// Ansible模块数据
export const ansibleModules = {
  // 系统模块
  'ping': {
    description: '测试主机连通性',
    parameters: []
  },
  'setup': {
    description: '收集主机信息',
    parameters: [
      'filter=ansible_*',
      'gather_subset=all',
      'gather_timeout=10'
    ]
  },
  'command': {
    description: '执行命令',
    parameters: [
      'cmd="command"',
      'chdir=/path',
      'creates=/path/file',
      'removes=/path/file',
      'warn=true'
    ]
  },
  'shell': {
    description: '执行shell命令',
    parameters: [
      'cmd="command"',
      'chdir=/path',
      'creates=/path/file',
      'removes=/path/file',
      'executable=/bin/bash'
    ]
  },
  'script': {
    description: '执行脚本',
    parameters: [
      'script.sh',
      'chdir=/path',
      'creates=/path/file',
      'removes=/path/file'
    ]
  },
  
  // 文件模块
  'copy': {
    description: '复制文件',
    parameters: [
      'src=/path/source',
      'dest=/path/dest',
      'backup=yes',
      'mode=0644',
      'owner=root',
      'group=root'
    ]
  },
  'file': {
    description: '管理文件和目录',
    parameters: [
      'path=/path/file',
      'state=file|directory|absent|touch',
      'mode=0644',
      'owner=root',
      'group=root',
      'recurse=yes'
    ]
  },
  'template': {
    description: '模板文件',
    parameters: [
      'src=template.j2',
      'dest=/path/dest',
      'backup=yes',
      'mode=0644',
      'owner=root',
      'group=root'
    ]
  },
  'fetch': {
    description: '从远程主机获取文件',
    parameters: [
      'src=/path/source',
      'dest=/path/dest',
      'flat=yes',
      'fail_on_missing=yes'
    ]
  },
  'synchronize': {
    description: '同步文件',
    parameters: [
      'src=/path/source',
      'dest=/path/dest',
      'delete=yes',
      'recursive=yes'
    ]
  },
  
  // 包管理
  'yum': {
    description: 'YUM包管理',
    parameters: [
      'name=package',
      'state=present|absent|latest',
      'update_cache=yes',
      'enablerepo=repo',
      'disablerepo=repo'
    ]
  },
  'apt': {
    description: 'APT包管理',
    parameters: [
      'name=package',
      'state=present|absent|latest',
      'update_cache=yes',
      'cache_valid_time=3600'
    ]
  },
  'package': {
    description: '通用包管理',
    parameters: [
      'name=package',
      'state=present|absent|latest'
    ]
  },
  'pip': {
    description: 'Python包管理',
    parameters: [
      'name=package',
      'state=present|absent|latest',
      'version=1.0',
      'virtualenv=/path/venv'
    ]
  },
  
  // 服务管理
  'service': {
    description: '服务管理',
    parameters: [
      'name=service',
      'state=started|stopped|restarted|reloaded',
      'enabled=yes|no'
    ]
  },
  'systemd': {
    description: 'Systemd服务管理',
    parameters: [
      'name=service',
      'state=started|stopped|restarted|reloaded',
      'enabled=yes|no',
      'daemon_reload=yes'
    ]
  },
  
  // 用户管理
  'user': {
    description: '用户管理',
    parameters: [
      'name=username',
      'state=present|absent',
      'uid=1000',
      'group=group',
      'groups=group1,group2',
      'home=/home/user',
      'shell=/bin/bash',
      'password=encrypted_password'
    ]
  },
  'group': {
    description: '组管理',
    parameters: [
      'name=groupname',
      'state=present|absent',
      'gid=1000'
    ]
  },
  
  // 网络模块
  'uri': {
    description: 'HTTP请求',
    parameters: [
      'url=http://example.com',
      'method=GET|POST|PUT|DELETE',
      'body=data',
      'headers={"Content-Type": "application/json"}',
      'status_code=200'
    ]
  },
  'get_url': {
    description: '下载文件',
    parameters: [
      'url=http://example.com/file',
      'dest=/path/dest',
      'mode=0644',
      'backup=yes'
    ]
  },
  
  // 数据库模块
  'mysql_user': {
    description: 'MySQL用户管理',
    parameters: [
      'name=username',
      'password=password',
      'priv=db.*:ALL',
      'state=present|absent',
      'host=localhost'
    ]
  },
  'mysql_db': {
    description: 'MySQL数据库管理',
    parameters: [
      'name=database',
      'state=present|absent',
      'collation=utf8_general_ci',
      'encoding=utf8'
    ]
  },
  
  // 云模块
  'ec2': {
    description: 'AWS EC2实例管理',
    parameters: [
      'image=ami-12345678',
      'instance_type=t2.micro',
      'key_name=my-key',
      'security_group=default',
      'state=present|absent|running|stopped'
    ]
  },
  
  // 容器模块
  'docker_container': {
    description: 'Docker容器管理',
    parameters: [
      'name=container',
      'image=nginx:latest',
      'state=started|stopped|absent',
      'ports=80:80',
      'volumes=/host:/container'
    ]
  },
  'docker_image': {
    description: 'Docker镜像管理',
    parameters: [
      'name=nginx:latest',
      'state=present|absent',
      'source=pull|build',
      'path=/path/to/dockerfile'
    ]
  },
  
  // Git模块
  'git': {
    description: 'Git仓库管理',
    parameters: [
      'repo=https://github.com/user/repo.git',
      'dest=/path/dest',
      'version=HEAD|branch|tag',
      'force=yes'
    ]
  },
  
  // 压缩模块
  'unarchive': {
    description: '解压文件',
    parameters: [
      'src=/path/archive.tar.gz',
      'dest=/path/dest',
      'remote_src=yes',
      'owner=root',
      'group=root'
    ]
  },
  'archive': {
    description: '压缩文件',
    parameters: [
      'path=/path/to/compress',
      'dest=/path/archive.tar.gz',
      'format=gz|bz2|xz|zip'
    ]
  },
  
  // 定时任务
  'cron': {
    description: '定时任务管理',
    parameters: [
      'name=job_name',
      'job="command"',
      'minute=0',
      'hour=0',
      'day=*',
      'month=*',
      'weekday=*',
      'state=present|absent'
    ]
  },
  
  // 挂载模块
  'mount': {
    description: '挂载管理',
    parameters: [
      'path=/mnt/point',
      'src=/dev/sdb1',
      'fstype=ext4',
      'state=mounted|unmounted|present|absent'
    ]
  },
  
  // 防火墙
  'firewalld': {
    description: 'Firewalld防火墙管理',
    parameters: [
      'service=http',
      'port=80/tcp',
      'zone=public',
      'state=enabled|disabled',
      'permanent=yes',
      'immediate=yes'
    ]
  },
  'iptables': {
    description: 'Iptables防火墙管理',
    parameters: [
      'table=filter',
      'chain=INPUT',
      'rule="-s 192.168.1.0/24 -j ACCEPT"',
      'state=present|absent'
    ]
  }
}

// 获取所有模块名称
export const getModuleNames = () => {
  return Object.keys(ansibleModules)
}

// 获取模块参数
export const getModuleParameters = (moduleName) => {
  return ansibleModules[moduleName]?.parameters || []
}

// 获取模块描述
export const getModuleDescription = (moduleName) => {
  return ansibleModules[moduleName]?.description || ''
}
